package com.bw.controller;

import com.bw.bean.Sugar2;
import com.bw.service.SugarService;
import com.sugar.SugarUtil;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@RestController
public class SugarController {
    @Autowired
    SugarService sugarService;

    @RequestMapping("/list1")
    public Map getList1(){
        double list1 = sugarService.getList1();
        Map<Object,Object> map=new HashMap<>();
        map.put("status",0);
        map.put("data",list1);
        return map;
    }

    @RequestMapping("/list2")
    public Map getList2(){
        List list2 = sugarService.getList2();
        return SugarUtil.getPieData(list2);
    }

    @RequestMapping("/list3")
    public String getList3(){
        List<Sugar2> list3 = sugarService.getList3();
        ArrayList<String> list=new ArrayList<>();
        list.add("机构");
        list.add("完运公里");
        list.add("完运时长");
        list.add("每次平均时长");
        list.add("每次平均里程");
        list.add("开窗");
        return SugarUtil.getTablePlayData(list,list3);
    }

    @RequestMapping("/list4")
    public Map getList4(){
        List list4 = sugarService.getList4();
        return SugarUtil.getMapData(list4);
    }
}
